<{include file='public/head'}>
<div class="layui-body">
	<div class="layui-tab layui-tab-brief" lay-filter="tab">
	  <ul class="layui-tab-title">
	    <li class="layui-this" lay-id="t1"><{$model_name}>内容</li>
	    <li lay-id="t2"><{$model_name}>新增</li>
	  </ul>
	  <div class="layui-tab-content">
	  	   <div class="layui-tab-item layui-show">
	  	   		<form action="<{:url('/Content/index/mcode/'.$UrlParam['mcode'].'')}>" method="get" class="layui-form">
				 <input type="hidden" name="lkid" value="<{$UrlParam['lkid']}>" >
		  	   		<div class="layui-form-item nospace">
		  	   			<div class="layui-input-inline">
					       <select name="scode">
	                          	<option value="">全部栏目</option>
                                <{$search_select}>
	                       </select>
					    </div>
	                     <div class="layui-input-inline">
	                     	<input type="text" name="keyword" placeholder="请输入搜索关键字" class="layui-input">
	                     </div>
	                     <div class="layui-input-inline">
	                     	<button class="layui-btn" lay-submit>搜索</button>
	                     	<a class="layui-btn layui-btn-primary"  href="<{:url('/Content/index/mcode/'.$UrlParam['mcode'].'')}>">清除搜索</a>
	                     </div>
	                </div>
                </form>

	  	   		<form action="<{:url('/Content/mod')}>" method="post" id="contentForm" name="contentForm" class="layui-form" onkeydown="if(event.keyCode==13) return false;">
		            <input type="hidden" name="formcheck" value="<{$formcheck}>" >
		            <table class="layui-table">
		            	<thead>
		                    <tr>
		                    	<th><input type="checkbox" class="checkbox" lay-ignore id="checkall" title="全选"></th>
		                    	<th>ID</th>
		                        <th>栏目</th>
								<{if condition="$UrlParam['lkid'] >0 || $UrlParam['mcode'] eq 3"}>
								 <th>关联</th>
								<{/if}>
		                        <th>标题</th>
		                        <th>发布时间</th>
		                        <th>排序</th>
		                        <th>状态</th>
		                        <th>置顶图</th>
		                        <th>推荐</th>
								<!--<th>幻灯</th>--->
		                        <th>访问量</th>
		                        <th>操作</th>
		                    </tr>
		                </thead>
		                <tbody>
							<{volist name="$contents" id="value"}>
		                    <tr>
		                    	<td>
		                    		<input type="checkbox" class="checkbox checkitem" lay-ignore name="list[]" <{if condition="$value.outlink"}> disabled <{/if}> value="<{$value.id}>">
		                    		<input type="hidden" name="listall[]" value="<{$value.id}>">
		                    	</td>
		                    	<td><{$value.id}></td>
		                        <td title="<{$value.scode}>"><{$value.sortname}></td>
								<{if condition="$UrlParam['lkid'] >0 || $UrlParam['mcode'] eq 3"}>
								 <th><{:getcontentfield($value.lkid,'title')}></th>
								<{/if}>
		                        <td title="<{$value.title}>">
		                       <{:msubstr($value.title,0,15)}>
								<!--<{if condition="$value.isslide"}>
		                        	<span class="layui-badge layui-bg-blue">幻</span>
		                        <{/if}>--->
		                       <{if condition="$value.ico"}>
		                        	<span class="layui-badge layui-bg-orange">缩</span>
		                        <{/if}>
								<{if condition="$value.pics"}>
		                        	<span class="layui-badge">图</span>
		                        <{/if}>
								<{if condition="$value.outlink"}>
	                            	<span class="layui-badge layui-bg-black">链</span>
	                            <{/if}>
		                        </td>

		                        <td><{$value.date}></td>
		                        <td class="table-input"><input type="text" lay-ignore class="layui-input" name="sorting[]" value="<{$value.sorting}>"></td>
		                        <td>
								<{if condition="$value.status"}>
			                        <a href="<{:url('/Content/mod/id/'.$value.id.'/field/status/value/0')}>"><i class='fa fa-toggle-on' title="点击关闭"></i></a>
			                        <{else}>
			                        <a href="<{:url('/Content/mod/id/'.$value.id.'/field/status/value/1')}>"><i class='fa fa-toggle-off' title="点击开启"></i></a>
			                    <{/if}>
			                    </td>
			                    <td>
								<{if condition="$value.istop"}>
			                        <a href="<{:url('/Content/mod/id/'.$value.id.'/field/istop/value/0')}>"><i class='fa fa-toggle-on' title="点击关闭"></i></a>
			                        <{else}>
			                        <a href="<{:url('/Content/mod/id/'.$value.id.'/field/istop/value/1')}>"><i class='fa fa-toggle-off' title="点击开启"></i></a>
			                    <{/if}>
			                    </td>

			                    <td>
								<{if condition="$value.isrecommend"}>
			                        <a href="<{:url('/Content/mod/id/'.$value.id.'/field/isrecommend/value/0')}>"><i class='fa fa-toggle-on' title="点击关闭"></i></a>
			                       <{else}>
			                        <a href="<{:url('/Content/mod/id/'.$value.id.'/field/isrecommend/value/1')}>"><i class='fa fa-toggle-off' title="点击开启"></i></a>
			                    <{/if}>
			                    </td>
								 <!--<td>
								<{if condition="$value.isslide"}>
			                        <a href="<{:url('/Content/mod/id/'.$value.id.'/field/isslide/value/0')}>"><i class='fa fa-toggle-on' title="点击关闭"></i></a>
			                        <{else}>
			                        <a href="<{:url('/Content/mod/id/'.$value.id.'/field/isslide/value/1')}>"><i class='fa fa-toggle-off' title="点击开启"></i></a>
			                    <{/if}>
			                    </td>--->
			                    <td><{$value.visits}></td>
		                        <td>
									<{if condition="!$value.outlink"}>
										<a href="<{$value.link}>" class="layui-btn layui-btn-xs layui-btn-primary"  target="_blank">查看</a>
										<{else}>
										<input type="hidden" name="urls[<{$value.id}>]" value="<{$value.outlink}>">
			                        	<a href="<{$value.outlink}>" class="layui-btn layui-btn-xs layui-btn-primary"  target="_blank">查看</a>
		                        	<{/if}>
		                            <{:get_btn_del($value.id,'Content')}>
		                            <a href="<{:url('/Content/mod/mcode/'.$UrlParam.mcode.'/id/'.$value.id.'')}>" class="layui-btn layui-btn-xs" >修改</a>

									<{if condition="$value.lkcode > 0"}>
										<a href="<{:url('/Content/index/mcode/'.getScodeInfo($value.lkcode,'mcode').'/lkid/'.$value.id.'')}>#tab=t2" class="layui-btn layui-btn-xs layui-btn-normal">添加<{:getScodeInfo($value.lkcode,'name')}></a>
		                        	<{/if}>
		                        </td>
		                    </tr>
		                    <{/volist}>
		                </tbody>
		            </table>
					<div>
						<div style="width: 150px;float: left;">
							 <select name="scode" style="width: 20%;" class="layui-input-inline">
									<option value="">请选择目标栏目</option>
									 <{$search_select}>
							 </select>
						</div>
						<div style="width: 200px;float:left;margin-left: 10px;">
								<button type="submit" name="submit" value="copy" class="layui-btn">复制</button>
								<button type="submit" name="submit" value="move" class="layui-btn">移动</button>
								<button type="submit" name="submit" onclick="return setDelAction();" class="layui-btn">批量删除</button>
						</div>
					</div>

			     	<!--<button type="submit" name="submit" value="sorting" class="layui-btn">保存排序</button>--->
					 <script>
			     		function setDelAction(){
			     			document.contentForm.action = "<{:url('/Content/del')}>";
			     			return confirm("您确定要删除选中的内容么？");
			     		}
			     	</script>
			     	<div class="page"><{$contents->render()}></div>
			      </form>
	  	   </div>

		   <div class="layui-tab-item">
	  	  		<form action="<{:url('/Content/add/mcode/'.$UrlParam['mcode'].'')}>" method="post" class="layui-form" lay-filter="content" id="edit" οnsubmit="return false">
		  	     	<input type="hidden" name="formcheck" value="<{$formcheck}>" >
					<input type="hidden" name="lkid" value="<{$UrlParam['lkid']}>" >
		  	     	<div class="layui-tab">
					  <ul class="layui-tab-title">
					    <li class="layui-this">基本内容</li>
					    <li>高级内容</li>
					  </ul>
					  <div class="layui-tab-content">
					    <div class="layui-tab-item layui-show">
					    	<div class="layui-form-item">
			                     <label class="layui-form-label">内容栏目   <span class="layui-text-red">*</span></label>
			                     <div class="layui-input-block">
			                     	<select name="scode" lay-verify="required">
				                        <option value="">请选择内容栏目</option>
			                        	<{$sort_select}>
				                    </select>
			                     </div>
			                </div>
			                <div class="layui-form-item">
			                     <label class="layui-form-label">内容标题   <span class="layui-text-red">*</span></label>
			                     <div class="layui-input-block">
			                     	<input type="text" name="title" required lay-verify="required" placeholder="请输入内容标题" class="layui-input">
			                     </div>
			                </div>
							<{volist name=":getwholelist(0,$UrlParam.mcode)" id="li" key="key"}>
							<div class="layui-form-item">
								<label class="layui-form-label"><{$li.TypeName}></label>
								<div class="layui-input-block">
									<select name="rund<{$key}>">
											<option value="">请选择<{$li.TypeName}></option>
											<{volist name=":getwholelist($li.TypeID,$UrlParam.mcode)" id="li2"}>
											<option value="<{$li2.TypeID}>"><{$li2.TypeName}></option>
											<{/volist}>
									</select>
								</div>
							 </div>
							 <{/volist}>
							<{volist name="$extfield" id="value"}>
			                	<{if condition="$value->type eq 1"}> <!-- 单行文本 -->
			                	<div class="layui-form-item">
			                		<label class="layui-form-label"><{$value->description}> <{if condition="$value->isture eq 1"}> <span class="layui-text-red">*</span><{/if}></label>
			                		<div class="layui-input-block">
				                    	<input type="text" name="<{$value->name}>"  placeholder="请输入<{$value->description}>"  class="layui-input">
				                	</div>
				                </div>
			                	<{/if}>
			                	<{if condition="$value->type eq 2"}><!-- 多行文本 -->
			                	<div class="layui-form-item">
			                		<label class="layui-form-label"><{$value->description}> <{if condition="$value->isture eq 1"}> <span class="layui-text-red">*</span><{/if}></label>
			                		<div class="layui-input-block">
				                		<textarea name="<{$value->name}>" class="layui-textarea" placeholder="请输入<{$value->description}>"></textarea>
				                	</div>
				                </div>
			                	<{/if}>
			                    <{if condition="$value->type eq 3"}><!-- 单选 -->
			                	<div class="layui-form-item">
			                		<label class="layui-form-label"><{$value->description}></label>
			                		<div class="layui-input-block">
				                		<div>
				                			<{php}>
				                				$radios=explode(',',$value->value);
				                				foreach ($radios as $value2) {
	                								echo '<input type="radio" name="'.$value->name.'" value="'.$value2.'" title="'.$value2.'">';
	            								}
	            						     <{/php}>
					                    </div>
				                	</div>
				                </div>
			                	<{/if}>
			                    <{if condition="$value->type eq 4"}><!-- 多选 -->
			                	<div class="layui-form-item">
			                		<label class="layui-form-label"><{$value->description}></label>
			                		<div class="layui-input-block">
				                		<div>
				                			<{php}>
				                				$checkboxs=explode(',',$value->value);
				                				foreach ($checkboxs as $value2) {
	            									echo '<input type="checkbox" name="'.$value->name.'[]" value="'.$value2.'" title="'.$value2.'">';
	            								}
	            						    <{/php}>
					                    </div>
				                	</div>
				                </div>
			                	<{/if}>
			                	<{if condition="$value->type eq 5"}><!-- 图片 -->
			                	<div class="layui-form-item">
			                		<label class="layui-form-label"><{$value->description}></label>
			                		<div class="layui-input-inline">
				                     	<input type="text" name="<{$value->name}>" id="<{$value->name}>" placeholder="请上传<{$value->description}>"  class="layui-input">
				                     </div>
				                     <button type="button" class="layui-btn upload watermark" data-des="<{$value->name}>">
									 	 <i class="layui-icon">&#xe67c;</i>上传图片
									 </button>
									 <div id="<{$value->name}>_box" class="pic"></div>
				                </div>
			                	<{/if}>
			                	<{if condition="$value->type eq 6"}><!-- 文件 -->
			                	<div class="layui-form-item">
			                		<label class="layui-form-label"><{$value->description}></label>
			                		<div class="layui-input-inline">
				                     	<input type="text" name="<{$value->name}>" id="<{$value->name}>" placeholder="请上传<{$value->description}>"  class="layui-input">
				                     </div>
				                     <button type="button" class="layui-btn file" data-des="<{$value->name}>">
									 	 <i class="layui-icon">&#xe67c;</i>上传文件
									 </button>
				                </div>
			                	<{/if}>
			                	<{if condition="$value->type eq 8"}><!-- 编辑器 -->
			                	<div class="layui-form-item">
			                		<label class="layui-form-label"><{$value->description}> <{if condition="$value->isture eq 1"}> <span class="layui-text-red">*</span><{/if}></label>
			                		<div class="layui-input-block">
				                		<script type="text/plain" id="editor_<{$value->name}>" name="<{$value->name}>" style="width:100%;height:240px;"></script>
				                		<script>
											//初始化编辑器
											$(document).ready(function (e) {
												var ue = UE.getEditor('editor_<{$value->name}>',{
													maximumWords:10000
												});
											})
										</script>
				                	</div>
				                </div>
			                	<{/if}>
			                	<{if condition="$value->type eq 9"}><!-- 下拉 -->
			                	<div class="layui-form-item">
			                		<label class="layui-form-label"><{$value->description}> <{if condition="$value->isture eq 1"}> <span class="layui-text-red">*</span><{/if}></label>
			                		<div class="layui-input-block">
			                			<select name="<{$value->name}>" <{if condition="$value->isture eq 1"}>lay-verify="required"<{/if}>>
			                				<{php}>
												echo '<option value="">请选择'.$value->description.'</option>';
				                				$selects=explode(',',$value->value);
				                				foreach ($selects as $value2) {
	                								echo '<option value="'.$value2.'">'.$value2.'</option>';
	            								}
	            						    <{/php}>
			                			</select>
				                	</div>
				                 </div>
			                	<{/if}>
			                 <{/volist}>


			                <div class="layui-form-item">
			                     <label class="layui-form-label">内容</label>
			                     <div class="layui-input-block">
			                     	<script type="text/plain" id="editor" name="content" style="width:100%;height:240px;"></script>
			                     </div>
			                </div>
			                <div class="layui-form-item">
			                     <label class="layui-form-label">tags</label>
			                     <div class="layui-input-block">
			                     	<input type="text" name="tags" placeholder="请输入文章tag，英文逗号隔开" class="layui-input">
			                     </div>
			                </div>

			               <div class="layui-form-item">
			                     <label class="layui-form-label">作者</label>
			                     <div class="layui-input-block">
			                     	<input type="text" name="author" placeholder="请输入作者" value="" class="layui-input">
			                     </div>
			                </div>

			                <div class="layui-form-item">
			                     <label class="layui-form-label">来源</label>
			                     <div class="layui-input-block">
			                     	<input type="text" name="source" placeholder="请输入来源" value="<{$companys->name}>" class="layui-input">
			                     </div>
			                </div>

			                <div class="layui-form-item">
			                     <label class="layui-form-label">缩略图</label>
			                     <div class="layui-input-inline">
			                     	<input type="text" name="ico" id="ico" placeholder="请上传缩略图"  class="layui-input">
			                     </div>
			                     <button type="button" class="layui-btn upload watermark" data-des="ico">
								 	 <i class="layui-icon">&#xe67c;</i>上传图片
								 </button>
								 <div id="ico_box" class="pic addedit"></div>
			                </div>
			                <div class="layui-form-item">
			                     <label class="layui-form-label">参数</label>
			                     <div class="layui-input-block">
									<input type="checkbox" name="istop" value="1" title="置顶图">
			                    	<input type="checkbox" name="isrecommend" value="1" title="推荐">
			                    	<!--<input type="checkbox" name="isheadline" value="1" title="精选">
									<input type="checkbox" name="isslide" value="1" title="幻灯">--->
			                     </div>
			                </div>
					    </div>

					    <div class="layui-tab-item ">
					    	<!--<div class="layui-form-item">
			                     <label class="layui-form-label">内容副栏目</label>
			                     <div class="layui-input-block">
			                     	<select name="subscode">
				                        <option value="">请选择内容副栏目</option>
			                        	<{$subsort_select}>
				                    </select>
			                     </div>
			                </div>--->

					   		 <div class="layui-form-item">
			                     <label class="layui-form-label">标题颜色</label>
			                     <div class="layui-input-inline">
			                     	<input type="text" name="titlecolor" placeholder="请选择标题颜色" value="#333333" class="layui-input jscolor <{hash:true}>">
			                     </div>
			                 </div>

			                 <div class="layui-form-item">
			                     <label class="layui-form-label">副标题</label>
			                     <div class="layui-input-block">
			                     	<input type="text" name="subtitle" placeholder="请输入副标题" class="layui-input">
			                     </div>
			                 </div>

			                  <div class="layui-form-item">
			                     <label class="layui-form-label">外链接</label>
			                     <div class="layui-input-block">
									<input type="hidden" name="filename" placeholder="" class="layui-input">
			                     	<input type="text" name="outlink" placeholder="请输入跳转外链接" class="layui-input">
			                     </div>
			                 </div>

			                 <div class="layui-form-item">
			                     <label class="layui-form-label">发布时间</label>
			                     <div class="layui-input-inline">
			                     	<input type="text" name="date" value="<{:date('Y-m-d H:i:s')}>" readonly placeholder="请选择发布时间"  class="layui-input datetime">
			                     </div>
			                     <div class="layui-form-mid layui-word-aux">温馨提示：设置未来时间可定时发布！</div>
			                </div>

			                <div class="layui-form-item">
		                		<label class="layui-form-label">附件</label>
		                		<div class="layui-input-inline">
			                     	<input type="text" name="enclosure" id="enclosure" placeholder="请上传附件"  class="layui-input">
			                     </div>
			                     <button type="button" class="layui-btn file" data-des="enclosure">
								 	 <i class="layui-icon">&#xe67c;</i>上传附件
								 </button>
			                </div>

			                <div class="layui-form-item">
			                     <label class="layui-form-label">SEO关键字</label>
			                     <div class="layui-input-block">
			                     	<input type="text" name="keywords" placeholder="请输入详情页SEO关键字" class="layui-input">
			                     </div>
			                </div>

			                <div class="layui-form-item">
			                     <label class="layui-form-label">SEO描述</label>
			                     <div class="layui-input-block">
			                     	<textarea name="description" placeholder="请输入详情页SEO描述" class="layui-textarea"></textarea>
			                     </div>
			                </div>

			                <div class="layui-form-item">
			                     <label class="layui-form-label">状态</label>
			                     <div class="layui-input-block">
			                     	<input type="radio" name="status" value="1" title="显示" checked>
									<input type="radio" name="status" value="0" title="隐藏">
			                     </div>
			                </div>
					    </div>
					  </div>
					</div>
					<div class="layui-form-item">
						 <div class="layui-input-block">
						    <button class="layui-btn" lay-submit id="btnSave">立即提交</button>
						    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
						 </div>
					</div>
			   </form>
	  	   </div>

	  </div>
	 </div>
</div>
<style>.placeHolder {border:dashed 2px gray; }</style>
<script type="text/javascript" src="__STATIC__/tongycjs/js/jquery.dragsort-0.5.2.min.js"></script>
<script type="text/javascript">
$("#pics_box").dragsort({
	dragSelector: "dl",
	dragSelectorExclude: "input,textarea,dd",
	dragBetween: false,
	dragEnd: saveOrder,
	placeHolderTemplate: "<dl class='placeHolder'><dt></dt></dl>"
});

function saveOrder() {
	var data = $("#pics_box dl dt img").map(function() {
		return $(this).data("url");
	}).get();
	$("input[name=pics]").val(data.join(","))
};
//保存验证
 $("#btnSave").click(function(){
    layui.use('form',function(){
       var form=layui.form;
       form.render();
       form.on("submit(content)",function(data){
			 console.info('开始保存');
			var isDisabled = $("#btnSave").addClass('layui-btn-disabled');
			$('#btnSave').attr('disabled', 'disabled');  // 添加属性
			if (isDisabled) {
				document.getElementById("edit").submit();
			}
       	return false;
       });
    });
  });
</script>
<script type="text/javascript" src="__STATIC__/tongycjs/js/jscolor.js"></script>
<{include file='public/ueditor'}>
<{include file='public/foot'}>